﻿using LianChuDemo.IDal.BaseInfoManagerDal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WenDangOne.DbModel.BaseInfoManager;
using WenDangOne.ViewModel.BaseInfoManagerView;
using WenDangOne.ViewModel.common;

namespace LianChuDemo.Bll.BaseInfoManagerBll
{
    public class RoleDbBll
    {
        private IRoleDb _iRoleDbDal;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iModuleDbDal">注入的dal</param>

        public RoleDbBll(IRoleDb iRoleDbDal)
        {
            _iRoleDbDal = iRoleDbDal;
        }
        public RoleDbView GetRoleViewById(int roleId)
        {
            return _iRoleDbDal.GetRoleViewById(roleId);
        }
        public PagerResult<RoleDb> SearchPage(SearchModel searchModel)
        {
            return _iRoleDbDal.SearchPage(searchModel);
        }

        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public int RoleDbAdd(RoleDbView view)
        {
            //添加当前日期
            view.creator_date = DateTime.Now;
            //添加人物名称
            view.creator_name = "zzz";
            return _iRoleDbDal.RoleDbAdd(view);
        }

        public bool RoleUpdate(RoleDbView view)
        {
            view.modifi_date = DateTime.Now;
            view.modifi_name = "lzh";
            return _iRoleDbDal.RoleUpdate(view);
        }

        //获取对应用户下面的角色获取，用中间表，进行联查获取
        //查询指定用户名下面的角色
        public List<RoleDb> GetRoleDbsByUserName(string userName)
        {
            return _iRoleDbDal.GetRoleDbsByUserName(userName);
        }
    }
}
